<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 	xmlns="http://www.w3.org/1999/xhtml"
    	xmlns:ui="http://java.sun.com/jsf/facelets"
    	xmlns:f="http://java.sun.com/jsf/core"
    	xmlns:h="http://java.sun.com/jsf/html"
    	xmlns:p="http://primefaces.org/ui"
    	xmlns:ec="http://www.b2cexpress.com.br/ecommerce"
    	xmlns:s="http://www.suricattus.com.br/jsf/ui"
		xmlns:sf="http://www.suricattus.com.br/jsf/fn"
    	xmlns:composite="http://java.sun.com/jsf/composite">
    	
	<composite:interface componentType="ordenacaoComponente" >
		<composite:attribute name="convertionType" required="true"  />
		<composite:attribute name="grupo" required="true"  />
		<composite:attribute name="item" required="false" />
		<composite:attribute name="lista" required="true" />
		<composite:attribute name="itemOriginal" required="false" />
		<composite:attribute name="renderFormPanel" required="false" default="true" />
		<composite:attribute name="titulo" required="true" />
	</composite:interface>
	
	<composite:implementation>
		<legend>
			<h:outputText value="#{cc.attrs.titulo}"/>
		</legend>
		
		<h:panelGroup>
			<div class="#{cc.attrs.renderFormPanel ? 'form-actions' : ''}">
				<ec:selecionarItemModal id="selecionarItemForm" widgetVarDialog="dlgItem" showGrupo="#{cc.attrs.grupo eq null}"
						headerDialog="#{labels['cadastro.categoria.kit.itens']}" grupo="#{cc.attrs.grupo}" lista="#{cc.listaOrdenacao}" item="#{cc.attrs.item}">
					<p:commandButton action="#{cc.adicionarItem(_itemPesquisa)}" value="#{labels['botao.incluir']}" 
							styleClass="btn btn-primary" update=":#{cc.attrs.clientId}:tableItem" oncomplete="dlgItem.hide()" process="@this" />
				</ec:selecionarItemModal>
			</div>
			<br />
		</h:panelGroup>
		
		<h:panelGroup id="tableItem" styleClass="row-fluid">
			<p:dataTable value="#{cc.listaOrdenacao}" var="_itemOrdenacao" rendered="#{not empty cc.listaOrdenacao}">
				<p:column style="width:7%;text-align:center" headerText="" rendered="#{cc.size gt 1}" >
					<p:commandLink action="#{cc.subirItem(_itemOrdenacao.ordenacao)}" update=":#{cc.attrs.clientId}:tableItem" 
							process="@this" rendered="#{_itemOrdenacao.ordenacao gt 1}">
						<i class="icon-arrow-up"/>
					</p:commandLink>
					<p:commandLink action="#{cc.descerItem(_itemOrdenacao.ordenacao)}" update=":#{cc.attrs.clientId}:tableItem" 
							process="@this" rendered="#{_itemOrdenacao.ordenacao lt cc.size}">
						<i class="icon-arrow-down"/>
					</p:commandLink>
				</p:column>
				<p:column style="width:2%;text-align:center" headerText="#{labels['label.ordenacao']}">
					<h:outputText value="#{_itemOrdenacao.ordenacao}" />
				</p:column>  
				<p:column style="width:25%"  headerText="#{labels['label.preview']}">
					<img src="#{_itemOrdenacao.item.icone.link}" width="50" />
				</p:column>  
				<p:column style="width:75%;" headerText="#{labels['label.item']}" >  
					<h:outputText value="#{_itemOrdenacao.item.titulo}" />  
				</p:column>  
				<p:column style="width:75%;text-align:center" headerText="#{labels['label.publicado']}" >  
					<h:outputText value="#{_itemOrdenacao.item.publicado.descricao}" />  
				</p:column>  
				<p:column style="width:75%;text-align:center"  headerText="#{labels['botao.excluir']}">  
					<p:commandLink action="#{cc.removerItem(_itemOrdenacao.ordenacao)}" update=":#{cc.attrs.clientId}:tableItem" process="@this">
						<i class="icon-remove" />
					</p:commandLink>
				</p:column>  
			</p:dataTable>
		</h:panelGroup>
	</composite:implementation>
	
</html>
